﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.MediaCenter.Hosting;

namespace RMC.Commands
{
	internal class VolumeCommand : ICommand
	{

		#region ICommand Members

		public string Syntax
		{
			get { return "volume <up|down|mute|unmute|switch>"; }
		}

		public string Help
		{
			get { return @"volume <up|down|mute|unmute|switch>

 - up     =
 - down   =
 - mute   =
 - unmute =
 - switch = switch between mune and unmute
 - ismute = return if mute is on
"; }
		}

		public CommandResult Execute(string args)
		{
			CommandResult cr = new CommandResult();

			if (args.Equals("switch", StringComparison.CurrentCultureIgnoreCase))
			{
				AddInHost.Current.MediaCenterEnvironment.AudioMixer.Mute = !AddInHost.Current.MediaCenterEnvironment.AudioMixer.Mute;
				cr.Type = CommandResultType.Executed;
			}
			else if (args.Equals("mute", StringComparison.CurrentCultureIgnoreCase))
			{
				AddInHost.Current.MediaCenterEnvironment.AudioMixer.Mute = true;
				cr.Type = CommandResultType.Executed;
			}
			else if (args.Equals("unmute", StringComparison.CurrentCultureIgnoreCase))
			{
				AddInHost.Current.MediaCenterEnvironment.AudioMixer.Mute = false;
				cr.Type = CommandResultType.Executed;
			}
			else if (args.Equals("up", StringComparison.CurrentCultureIgnoreCase))
			{
				AddInHost.Current.MediaCenterEnvironment.AudioMixer.VolumeUp();
				cr.Type = CommandResultType.Executed;
			}
			else if (args.Equals("down", StringComparison.CurrentCultureIgnoreCase))
			{
				AddInHost.Current.MediaCenterEnvironment.AudioMixer.VolumeDown();
				cr.Type = CommandResultType.Executed;
			}
			else if (args.Equals("ismute", StringComparison.CurrentCultureIgnoreCase))
			{
				cr.Content = AddInHost.Current.MediaCenterEnvironment.AudioMixer.Mute.ToString().ToLower();
				cr.Type = CommandResultType.ExecutedWithContent;
			}
			else
			{
				cr.Type = CommandResultType.BadArguments;
			}

			return cr;
		}

		#endregion
	}
}
